import java.util.Comparator;


public class ProcessingUnitComparator implements Comparator<IProcessingUnit>
{

	@Override
	public int compare(IProcessingUnit arg0, IProcessingUnit arg1) 
	{
		double powerConsumption0 = arg0.getPowerConsumption();
		double powerConsumption1 = arg1.getPowerConsumption();
		
		if(powerConsumption0 < powerConsumption1)
			return -1;
		else if(powerConsumption0 > powerConsumption1)
			return 1;
		else
		{
			long freeMemory0 = arg0.getFreeMemory();
			long freeMemory1 = arg1.getFreeMemory();
			
			if(freeMemory0 < freeMemory1)
				return -1;
			else if(freeMemory0 > freeMemory1)
				return 1;
			else return 0;
		}
	}

}
